#include "stm8l15x.h"
#include <ctype.h>
#include <stdio.h>
#include "unit_instance.h"
#include "usart.h"
#include <stdlib.h>
#include "cmdthread.h"

#include "string.h"
#include "pubset.h"

#include "formatcmd.h"
 
 
extern char ComData[500];



char
cmd_wram (char *s)
{
   const char prev[] =
    "The mcu chip write  context (addr)=value\nexample:   addr[0x0000]=(0x56)\r\nThis addr len must 4\r\n";
  char succ[] = "The wram(0xxxxx) value =0xxx\r\n";
   u32 laddr;
  char cvalue;
  

if ( ERROR == getladdr( _incmdtext1,4, &laddr))
	{
		 printf ( "%s\r\n",  prev );
      return SUCCESS;
		}
   
	 if ( ERROR ==get_value ( _incmdtext1   ,&cvalue))
	 {
		   printf ( "%s\r\n",  prev );
      return SUCCESS;
		}
   
	*( ( u8 *)laddr  ) = cvalue ; 
		cvalue = *( ( u8 *)laddr  ) ;
	
printf ( "The wram(0x%02x%04x) value =0x%02x\n",(u16) (laddr /0xffff),*((unsigned int *)( &laddr)+1) ,(u16)cvalue ) ; 

   return SUCCESS;
}
